﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Frame.Lib.Core.Base;

namespace Frame.Lib.Core.Para
{
    public class ParaDAL : BaseDAL
    {
        internal void Update(ParaInfo info, string oldID)
        {
            string sql = "update " + STableName.Para + " set ID=@p0,Value = @p1,Remark=@p2,Orders=@p3 where ID=@p4";
            dbOper.RunSql(sql, info.ID, info.Value, info.Remark,info.Orders, oldID);
        }

        internal bool ExsitKey(string newKey, string oldKey)
        {
            string sql = "select count(*) from " + STableName.Para + " where ID =@p0";
            if (!string.IsNullOrEmpty(oldKey))
            {
                sql += " and ID <> @p1";
            }

            int count = dbOper.GetScalar<int>(sql, newKey, oldKey);
            return count > 0;
        }
    }

}
